# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Christian Rebischke <chris.rebischke[at]archlinux[dot]org>

pkgname=bettercap
pkgver=2.32.0
pkgrel=2
pkgdesc='Swiss army knife for network attacks and monitoring'
url='https://github.com/bettercap/bettercap'
arch=('loong64' 'x86_64')
license=('GPL3')
depends=('glibc' 'libpcap' 'libpcap.so' 'libnetfilter_queue' 'iproute2' 'libnfnetlink' 'libusb' 'libusb-1.0.so')
makedepends=('go' 'git')
optdepends=('bettercap-caplets: scripts (caplets) and proxy modules')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('0728d2dab0c0a07fdfd91490f450be46b004ae994024bfdb6ef1b7ecac8044c4c70da9fdf986b9b31033c9698fb63e4f619604095727fb26d9ba2abc233b27d1')
b2sums=('f322c0a49cb13beb067ee4f993795b715e505e6db34472bcf9cd687047a3b7bbe0b6dda8e57b082e7bdb09810680a3a99ccc4a34fa118c33e575c7572095c4ab')

prepare() {
  cd ${pkgname}-${pkgver}
  find . -type f -exec sed 's|/usr/local|/usr|g' -i {} +
}

build() {
  cd ${pkgname}-${pkgver}
  export GO11MODULE=on
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"
  go build
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 bettercap -t "${pkgdir}/usr/bin"
  install -Dm 644 bettercap.service -t "${pkgdir}/usr/lib/systemd/system"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
